package leetcode.weekly.week334;

import java.util.Arrays;

import leetcode.helper.H;

//Solution3Test
public class Solution3 {
	public int maxNumOfMarkedIndices(int[] nums) {
		Arrays.sort(nums);
		int ans = nums.length;
		int l = 0, r = nums.length - 1;
		while (l <= r) {
			int m = ((r - l) >> 1) + l;
			int i = m;
			for (int j = 0; i < nums.length && j < m; i++, j++) {
				if (nums[j] * 2 > nums[i]) {
					break;
				}
			}
			if (i == nums.length) {
				ans = m;
				r = m - 1;
			} else {
				l = m + 1;
			}
		}
		return (nums.length - ans) << 1;
	}


}
